package com.wichatbackapi.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 自定义 Knife4jConfig 接口文档的配置
 * @author wang
 */
@Configuration
public class Knife4jConfig {
    @Value("${system.name}")
    private String name;
    @Value("${system.version}")
    private String version;
    @Value("${system.author}")
    private String author;
    @Bean
    public OpenAPI springOpenAPI() {
        return new OpenAPI()
                .info(new Info().
                        title(name+"接口文档")
                        .description(name+"系统API文档")
                        .version(version)
                        .contact(new Contact().name(author).email("patrick@gmail.com"))
                        .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                        .externalDocs(new ExternalDocumentation()
                        .description("外部文档")
                        .url("https://springshop.wiki.github.org/docs"));
    }
}

